<!--
/**************************************************
* @ balpayrecvadd.jsp
*
* Copyright 2006 Hitrust Technology Inc.
* Developed by SDC, Hitrust.
* All Rights Reserved.
*
* Modify History:
*  v1.00, 2006/05/16, Jenny Li
*  1) first release
/**************************************************
-->
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ include file="../../common.jsp" %>
<%@ taglib uri="/page.util.gs.hitrust.com/taglibs/page" prefix="page"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
	<title>应收应付录入</title>
	<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<LINK href="<%=root%>/css/caigouxitong.css"" type=text/css rel=stylesheet>		
	<SCRIPT language="JavaScript" src="<%=root%>/js/common.js"></SCRIPT>
	<SCRIPT language="JavaScript" src="<%=root%>/js/calendar.js"></SCRIPT>
	<SCRIPT language="JavaScript" src="<%=root%>/js/hi-check.js"></SCRIPT>	
	<%
		HashMap tMap = (HashMap)request.getAttribute("orderdept");
		ArrayList tOrderDeptList = (ArrayList)tMap.get("organization");
		ArrayList tList = (ArrayList)request.getAttribute("feetype");
	%>	
	<script>
	var counter;
	function process(val){
		if(val == 'C'){     
			if(balpayrecvaddform.aDeptCategory.value == '2'){
				if(isEmpty(balpayrecvaddform.aProvider.value )){
					alert("如果选择公司类型为供应商，则供应商栏必填!");
					return false;
				}
//				if(balpayrecvaddform.aPayType.value != '2'){
//					alert("如果选择公司类型为供应商，则必须选择费用类型为付款!");
//					return false;
//				}
			}else if(balpayrecvaddform.aDeptCategory.value == '1'){
//				if(balpayrecvaddform.aPayType.value != '1'){
//					alert("如果选择公司类型为订货单位，则必须选择费用类型为收款!");
//					return false;
//				}
			}
			var iFields1  = new Array();
       		iFields1[0] = 'aSum||金额||Y||1-20||#.';
			if(HiScript.value('balpayrecvaddform',iFields1)==false) {
				return false;
			} 			
			var icheckChar = "0123456789.";			
			if(HiScript.checkDecimal(balpayrecvaddform.aSum.value,icheckChar,'4','金额')){
				return false;
			}

			if(isEmpty(balpayrecvaddform.aPayDate.value)){
				alert("收款日期不能为空!");
				return false;
			}
			if(isEmpty(balpayrecvaddform.aPrincipal.value)){
				alert("负责人不能为空!");
				return false;			
			}else{
				if(StrLen(balpayrecvaddform.aPrincipal.value)>20){
					alert("负责人中文长度不能超过10个字符，英文不超过20个字符!");
					return false;
				}
			}
			if(!isEmpty(balpayrecvaddform.aNotes.value)){
				if(StrLen(balpayrecvaddform.aNotes.value) > 1000){
					alert("备注中文长度不能超过500个字符，英文不超过1000个字符!");
					return false;
				}
			}			
			var obj = new Array();
			obj[0] = balpayrecvaddform.aOrderDeptId.value;
			obj[1] = balpayrecvaddform.aProvider.value;
			obj[2] = balpayrecvaddform.aDeptCategory.value;
			obj[3] = balpayrecvaddform.aBalanceYear.value;
			obj[4] = balpayrecvaddform.aBalanceMonth.value;
			obj[5] = balpayrecvaddform.aFeeType.value;
			obj[6] = balpayrecvaddform.aPayType.value;
			obj[7] = balpayrecvaddform.aSum.value;
			obj[8] = balpayrecvaddform.aNotes.value;
			obj[9] = balpayrecvaddform.aPayDate.value;
			obj[10] = balpayrecvaddform.aPrincipal.value;
			window.returnValue = obj;
			window.close();																								
		}
	}
	function changeDept(val){
		if(val == '1'){
			document.all.orderdepttitle.style.display = "block";
			document.all.orderdeptval.style.display = "block";
			document.all.providertitle.style.display = "none";			
			document.all.providercontent.style.display = "none";
		}else if(val == '2'){
			document.all.orderdepttitle.style.display = "none";
			document.all.orderdeptval.style.display = "none";
			document.all.providertitle.style.display = "block";			
			document.all.providercontent.style.display = "block";		}
	}
	</script>
	</head>
	<body BGCOLOR="#f2f2f2" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
		<form name="balpayrecvaddform" method="post">
			<p><FONT face="宋体"></FONT><FONT face="宋体"></FONT><br>
			</p>
			<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
				<tr>
					<td height="20">
						<table width="100%" border="0" cellspacing="0" cellpadding="1">
							<tr height="20">
								<td height="30" width="758" class="mtxt_black">应收应付录入
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td class="bg_line" height="2"></td>
				</tr>
			</table>
			<br>
			<table class="bg_table" id="Table1" style="PADDING-RIGHT: 5px; PADDING-LEFT: 5px" cellSpacing="1"
				cellPadding="0" width="98%" align="center" border="0">
				<TR height="20">
					<TD class="bg_column" align="center" width="15%">公司类型</TD>
					<TD class="bg_row_odd" width="35%" colspan="3">
						<select id="Select2" name="aDeptCategory" onChange="changeDept(this.value)">
							<%
								String balType = request.getParameter("aDeptCategory");
								String[][] tRs = GSBaseManager.getAllBalanceType();
								for(int i=0; i < tRs.length; i++){
								    String[] temp = tRs[i];
								    if(balType != null && balType.equals(temp[0])){
							%>
							<option value="<%=temp[0]%>" selected><%=temp[1]%></option>								
							<%
								    }else{
							%>
							<option value="<%=temp[0]%>"><%=temp[1]%></option>							
							<%	    
								    }
								}
							%>
						</select>
					</TD>			
				</TR>
				<TR height="20">
					<TD class="bg_column" align="center" width="15%" id="orderdepttitle">订货单位</TD>
					<TD class="bg_row_odd" width="35%" id="orderdeptval">
						<select name="aOrderDeptId">			
						<%
							String tOrderDept = request.getParameter("aOrderDeptId");
							if(tOrderDeptList != null && tOrderDeptList.size() > 0 ){	
									for(int i=0; i<tOrderDeptList.size(); i++){
									    String[] temp = (String[])tOrderDeptList.get(i);
										if(tOrderDept != null && tOrderDept.equals(temp[0])){
							%>
											<option value="<%=temp[0]%>" selected>
											<%=temp[1]%></option>
							<%				    
										}else{
							%>
											<option value="<%=temp[0]%>"><%=temp[1]%></option>
							<%			
										}
									}
							    }

						%>
						</select>					

					</TD>
					<TD id="providertitle" class="bg_column" align="center" width="15%" style='display:none'>供应商</TD>
					<TD id="providercontent" class="bg_row_odd" width="35%" style='display:none'>
					<INPUT type="text" name="aProvider" maxlength="20" value="<%=request.getParameter("aProvider")== null?"":request.getParameter("provider")%>">（简称完全匹配）
					</TD>
				
					<TD class="bg_column" align="center">月份</TD>
					<TD class="bg_row_odd">
						<SELECT ID="Select2" NAME="aBalanceYear">
						<%
							String tSelYear = request.getParameter("aBalanceYear");
							int length = 15;
							Calendar cal = Calendar.getInstance();
							int curYear = cal.get(Calendar.YEAR);
							for(int i=0; i<length; i++){
								if(tSelYear != null){
									if(tSelYear.equals(String.valueOf(2006+i))){
						%>
									<OPTION value="<%=2006+i%>" selected><%=2006+i%></OPTION>		
						<%			
									}else{
						%>
									<OPTION value="<%=2006+i%>"><%=2006+i%></OPTION>						
						<%				
									}
								}else if(curYear == (2006 + i)){
						%>
							<OPTION value="<%=2006+i%>" selected><%=2006+i%></OPTION>						
						<%	        
							    }else{
						%>
							<OPTION value="<%=2006+i%>"><%=2006+i%></OPTION>						
						<%		    
							    }
							}
						%>
						</SELECT>年
						<SELECT ID="Select3" NAME="aBalanceMonth" >
						<%
							String tSelMonth = request.getParameter("aBalanceMonth");
							int curMonth = cal.get(Calendar.MONTH);
							for(int i=1; i<=12; i++){
								if(tSelMonth != null){
									if(tSelMonth.equals(String.valueOf(i))){
						%>
									<OPTION value="<%=i%>" selected><%=i%></OPTION>	
						<%			
									}else{
						%>
									<OPTION value="<%=i%>"><%=i%></OPTION>												
						<%			
									}
								}else if(curMonth + 1 == i){
						%>
									<OPTION value="<%=i%>" selected><%=i%></OPTION>						
						<%
								}else{
						%>		
									<OPTION value="<%=i%>"><%=i%></OPTION>												
						<%		    
							    }
							}
						%>
						</SELECT>月
					</TD>					
					</tr>
					<TR height="20">
					<TD class="bg_column" align="center" width="15%">费用类型</TD>
					<TD class="bg_row_odd" width="35%">
						<select id="Select5" name="aFeeType">
							<%
								String costTp = request.getParameter("aFeeType");
								//tRs = GSBaseManager.getAllCostType();
								for(int i=0; i < tList.size(); i++){
									GSBalanceFeeBean temp = (GSBalanceFeeBean)tList.get(i);
								    if(costTp != null && costTp.equals(temp.getGs_fee_type_no())){
							%>
									<option value="<%=temp.getGs_fee_type_no()%>" selected><%=temp.getGs_fee_type()%></option>								    	
							<%
								    }else{
							%>
									<option value="<%=temp.getGs_fee_type_no()%>"><%=temp.getGs_fee_type()%></option>							
							<%	    }
								}
							%>
						</select>					
						<select id="Select6" name="aPayType">
							<%
								String payTp = request.getParameter("aPayType");
								tRs = GSBaseManager.getAllPayType();
								for(int i=0; i < tRs.length; i++){
								    String[] temp = tRs[i];
								    if(payTp != null && payTp.equals(temp[0])){
							%>
									<option value="<%=temp[0]%>" selected><%=temp[1]%></option>								    	
							<%
								    }else{
							%>
									<option value="<%=temp[0]%>"><%=temp[1]%></option>							
							<%	    }
								}
							%>
						</select>
					</TD>
					<TD class="bg_column" align="center" width="15%">金额</TD>
					<TD class="bg_row_odd" width="35%">
						<input type="text" name="aSum" maxlenth="20" >元
					</TD>
				</tr>
				<TR height="20">
					<TD class="bg_column" align="center" width="15%">
						收款日期
					</TD>
					<TD class="bg_row_odd" width="15%">
						<input type="text" name="aPayDate" onfocus='setday(this)' readonly>
					</TD>					
					<TD class="bg_column" align="center" width="15%">
						负责人
					</TD>					
					<TD class="bg_row_odd" width="15%">
						<input type="text" name="aPrincipal" maxlength="20">
					</TD>						
				</TR>				
			</table>
			<p>
			<table class="bg_table" id="Table2" style="PADDING-RIGHT: 5px; PADDING-LEFT: 5px" cellSpacing="1"
				cellPadding="0" width="98%" align="center" border="0">
				<TR height="20">
					<TD class="bg_column" align="center" width="15%">
						备注
					</TD>				
					<TD class="bg_column" align="center" colspan="3">
						<textarea name="aNotes" maxlength="500" rows="5" cols="100"></textarea>
					</td>
				</tr>
			
			</table>
			
			
		</form>
		<p align="center">
			<INPUT type="button" value="确定" class="kuang" ID="Button1" NAME="Button1" onclick="process('C')">&nbsp;&nbsp;
			<INPUT type="button" value="关闭" ID="Button2" NAME="Button2" class="kuang" onClick="window.close();">
		</p>
</body>
</html>

